/**
 * 
 */
package br.com.locasis.view.validator;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.intercept.BypassInterceptors;


/**
 * @author marco.nascimento
 */
@org.jboss.seam.annotations.faces.Validator
@Name("bigDecimalValidatorMoeda")
@BypassInterceptors
public class BigDecimalValidatorMoeda implements Validator {
	
	@Override
	public void validate(FacesContext facesContext, UIComponent uiComponent, Object obj) throws ValidatorException {
	    if(obj != null && obj.toString().replace(".", "").length() > 13) {
	        throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "A quantidade de digitos não pode exceder 13 caracteres."));
	    }
	}
}